package com.hpjpw.idoapp.controller;

import com.hpjpw.idoapp.domain.LoginFormVo;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.service.SysLoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录验证
 *
 * @author hpj
 */
@Api(value ="用户登录")
@RestController
@RequestMapping("/ido")
public class IDoLoginController {
    @Autowired
    private SysLoginService loginService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginFormVo loginFormVo) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = Constants.TOKEN_PREFIX + loginService.login(loginFormVo.getUsername(), loginFormVo.getPassword());
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }

}
